package com.zzxy.springmvc12.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import po.Student;
import po.StudentExt;


@Controller
@RequestMapping("/stu")
public class StudentComtroller {
    @RequestMapping( "register")
    public String register() {
        return "/user/register";
    }

     @RequestMapping("insert")
     public @ResponseBody Student insert (@ResponseBody Student student){
        student.setPassword(student.getPassword()+":qwe");
        student.setUsername(student.getUsername()+":asd");
        return student;
        //service > MyBatis
     }

    @RequestMapping("/addStu")
    public String addStu(String username,String password) {
        System.out.println(username);
        System.out.println(password);
        // service > dao > insert into student ...
        return "/user/userlist";
    }

    @RequestMapping("/addStu")
    public String addStu2(StudentExt ext) {
        System.out.println(ext);
        for (Student student : ext.getStudentList()) {
            System.out.println(student);
        }
        // service > dao > insert into student ...
        return "/user/userlist";
    }
    @RequestMapping("/addStu2")
    public String addStu2(StudentExt ext) {
        System.out.println(ext);
        /*for (Student student : ext.getStudentList()) {
            System.out.println(student);
        }*/
        // service > dao > insert into student ...
        return "/user/userlist";
    }
    @RequestMapping("/text")
    public String text(@RequestMapping(required = true,defaultValue = "19",name = "id") int id) {
        System.out.println("id:" + id);
        return "forword:"
                return "forword:/stu/register.dp";
    }
    @RequestMapping("/text1")
    public String text1() {
        return "redirect:/stu/register.do";
    }


}
